/*******************************************************************
 *
 * Copyright (C), 2021-2022, Letstrong, All rights reserved.
 *
 * Author      : 
 * Create Time : 2020-12-12
 * Version     : v0.1
 * Description : 
 *******************************************************************/
 
/*----------------------------Head file----------------------------*/
#include "hal_flash.h"
#include "user_config.h"

/*----------------------------macro file---------------------------*/

/*----------------------------type define--------------------------*/

/*----------------------------var define---------------------------*/

/*-------------------------func declaration------------------------*/

/*-----------------------------------------------------------------*/


#if 0
#include "log.h"
//Can erase min sector unit is 0x200 Bytes.
void hal_flash_test(void)
{
	uint32_t erase_addr = 0x27000;
	uint32_t erase_addr1 = 0x27200;
	uint32_t erase_addr2 = 0x27300;
	uint32_t write_addr = 0x27100;
	uint8_t tx_buf[3] = {0x11, 0x22, 0x33};
	uint8_t rx_buf[3] = {0, 0, 0};

	hal_flash_write(write_addr, tx_buf, 3);
	hal_flash_read(write_addr, rx_buf, 3);
	LOG_DEBUG("test1, %x:%x:%x\r\n", rx_buf[0], rx_buf[1], rx_buf[2]);

	hal_flash_erase_sector(erase_addr);
	hal_flash_read(write_addr, rx_buf, 3);
	LOG_DEBUG("test2, %x:%x:%x\r\n", rx_buf[0], rx_buf[1], rx_buf[2]);

	hal_flash_erase_sector(erase_addr2);
	hal_flash_read(write_addr, rx_buf, 3);
	LOG_DEBUG("test4, %x:%x:%x\r\n", rx_buf[0], rx_buf[1], rx_buf[2]);

	hal_flash_erase_sector(erase_addr1);
	hal_flash_read(write_addr, rx_buf, 3);
	LOG_DEBUG("test3, %x:%x:%x\r\n", rx_buf[0], rx_buf[1], rx_buf[2]);
}
#endif


